<template>
  <template v-for="(item, index) in userMenu" :key="index">
    <el-sub-menu
      :index="item.path"
      v-if="
        item.children &&
        item.children.length > 0 &&
        item.children[0].menuType == 1
      "
    >
      <template #title>
        <el-icon>
          <template v-if="item.icon">
            <component :is="item.icon"></component>
          </template>
        </el-icon>
        <span>{{ item.menuName }}</span>
      </template>
      <TreeMenu :userMenu="item.children" />
    </el-sub-menu>
    <el-menu-item :index="item.path" v-else>
      <template #title v-if="item.icon">
        <component :is="item.icon"></component>
      </template>
      <span>{{ item.menuName }}</span>
    </el-menu-item>
  </template>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
import requestApi from "../api/requestApi";
defineProps<{
  userMenu: object[];
}>();
</script>

<style lang="scss" scoped></style>
